#include "stdafx.h"
#include "ASN1ObjectIdentifier.h"

typedef std::pair<std::string, std::vector<byte>> oidEncodingParam;

class ASN1OIDEncodingTestCase : public ::testing::TestWithParam<oidEncodingParam>
{
};

TEST_P(ASN1OIDEncodingTestCase, Encode)
{
	AppliedCryptography::ASN1ObjectIdentifier val(GetParam().first);
	std::vector<byte> ret;

	ret = val.encode();

	// Output size should be as expected
	ASSERT_EQ(GetParam().second.size(), ret.size()) << "Value: " << GetParam().first;

	for(unsigned int i = 0; i < GetParam().second.size(); ++i)
	{
		EXPECT_NO_THROW(EXPECT_EQ((int)GetParam().second.at(i), (int)ret.at(i)) 
			<< "Index i: " << i << "\n"
			<< "Value: " << GetParam().first);
	};
};

std::string str2("1.2.840.113549");
byte bytesStr2[] = {0x06, 0x06, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d};
std::vector<byte> vectStr2(bytesStr2, bytesStr2 + sizeof(bytesStr2) / sizeof(byte));

INSTANTIATE_TEST_CASE_P(ASN1OIDEncodingTest,
                        ASN1OIDEncodingTestCase,
						::testing::Values( 
							oidEncodingParam(str2, vectStr2) )
						);

